package com.haha.Services.impls;

import com.haha.Beans.Book;
import com.haha.Mappers.BookMapper;
import com.haha.Services.IBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class BookService implements IBookService {
    @Autowired
    private BookMapper bookMapper;
    @Override
    public List<Book> getBooks(){
        return this.bookMapper.getAllBooks();
    }
    @Override
    public Integer getBooksCount(){
        return this.bookMapper.getAllBooksCount();
    }

    @Override
    public Book selectBookById(Integer id){
        return this.bookMapper.selectById(id);
    }
    @Override
    public Integer insertBook(Book record){
        return this.bookMapper.insertBook(record);
    }
    @Override
    public Integer deleteBook(Integer record){
        return this.bookMapper.deleteBook(record);
    }
    @Override
    public Book updateBook(Integer id, Book record){
        return this.bookMapper.updateBook(id, record) > 0 ? record : null;
    }
}
